//
//  HSTableQRViewController.m
//  hsdyOrderSystem
//
//  Created by 赖国锋 on 2017/11/8.
//  Copyright © 2017年 赖国锋. All rights reserved.
//

#import "HSTableQRViewController.h"
#import "HSAddQRViewController.h"
#import "HSTableDetailVC.h"
@interface HSTableQRViewController ()

@end

@implementation HSTableQRViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"二维码";
}

-(void)initViews{
    [self setUpBarButtonItems];
    [self initTableView];
}

-(void)setUpBarButtonItems{
    UIButton* rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    rightBtn.frame = CGRectMake(0, 0, 80, 40);
    [rightBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 15, 0, -15)];
    [rightBtn setTitle:@"添加桌位" forState:UIControlStateNormal];
    rightBtn.titleLabel.font = FONT(14);
    [rightBtn addTarget:self action:@selector(rightBtnItemClick) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem =[[UIBarButtonItem alloc] initWithCustomView:rightBtn];
}

-(void)rightBtnItemClick{
    HSAddQRViewController *addvc = [HSAddQRViewController new];
    [self.navigationController pushViewController:addvc animated:YES];
}

-(void)initTableView{
    [self initTableViewWithStyle:UITableViewStylePlain];
//    self.tableView.delegate = self;
//    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view);
        make.left.right.bottom.equalTo(self.view);
    }];
    self.tableView.estimatedRowHeight = 50;
}

#pragma mark - UITableView DataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellInde = @"QRcell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellInde];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellInde];
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.text = @"xxxx";
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    
    HSTableDetailVC *detailvc = [HSTableDetailVC new];
    [self.navigationController pushViewController:detailvc animated:YES];
}

@end
